unit uXYList;

interface

uses Classes;

type
  _XYRECORD = record
    X,Y: single;
  end;
  PXYRecord = ^_XYRECORD;

  TXYList = class(TList)
  private
    function RGet(Index: Integer): PXYRecord;
  protected
    procedure Notify(Ptr: Pointer; Action: TListNotification); override;
  public
    function Add(X,Y: single): Integer;
    procedure Clear; override;

    property Items[Index: Integer]: PXYRecord read RGet; default;
  end;

implementation

{ TXYList }

function TXYList.Add(X, Y: single): Integer;
var prc: PXYRecord;
begin
  GetMem(prc, SizeOf(_XYRecord));
  prc^.X := X;
  prc^.Y := Y;
  Result := inherited Add(prc);
end;

procedure TXYList.Clear;
begin
  while Count>0 do
    Delete(Count-1);
  inherited;
end;

procedure TXYList.Notify(Ptr: Pointer; Action: TListNotification);
begin
  if (Action=lnDeleted) and (Ptr<>nil) then FreeMem(ptr);
end;

function TXYList.RGet(Index: Integer): PXYRecord;
begin
  Result := PXYRecord(inherited Items[index]);
end;

end.
